//
//  InvoiceViewController.m
//  AnXin100
//
//  Created by 王合润 on 10/25/18.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "InvoiceViewController.h"

@interface InvoiceViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *mainTable;

@property (nonatomic, strong) UIView *typeView;

@property (nonatomic, strong) UIView *editView;
@end

@implementation InvoiceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [PublicMonMethods setupNavigationItems:self];
    [PublicMonMethods settitle:@"发票抬头" viewController:self];
    [self.view addSubview:self.mainTable];
    [self.view addSubview:self.typeView];
    [self.view addSubview:self.editView];
}

- (UITableView *)mainTable {
    if (!_mainTable) {
        
        _mainTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, 150) style:UITableViewStylePlain];
//        _mainTable.delegate = self;
//        _mainTable.dataSource = self;
        _mainTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        
    }
    return _mainTable;
}

- (UIView *)typeView {
    if (!_typeView) {
        _typeView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_mainTable.frame), SCREEN_WIDTH, 47)];
        UIView *topLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
        topLineView.backgroundColor = [UIColor colorWithHex:0xE6E6E6];
        [_typeView addSubview:topLineView];
        
        UIView *buttonLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 45, SCREEN_WIDTH, 1)];
        buttonLineView.backgroundColor = [UIColor colorWithHex:0xE6E6E6];
        [_typeView addSubview:buttonLineView];
        
        UIButton *personalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        personalBtn.frame = CGRectMake(20, 13.5, 70, 20);
        [personalBtn setTitle:@"企业" forState:UIControlStateNormal];
        [personalBtn setTitleColor:[UIColor colorWithHex:0x666666] forState:UIControlStateNormal];
        personalBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [personalBtn setImage:[UIImage imageNamed:@"selec"] forState:UIControlStateNormal];
        personalBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
        [_typeView addSubview:personalBtn];
        
        UIButton *enterpriseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        enterpriseBtn.frame = CGRectMake(CGRectGetMaxX(personalBtn.frame) + 20, 13.5, 70, 20);
        [enterpriseBtn setTitle:@"个人" forState:UIControlStateNormal];
        [enterpriseBtn setTitleColor:[UIColor colorWithHex:0x666666] forState:UIControlStateNormal];
        enterpriseBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [enterpriseBtn setImage:[UIImage imageNamed:@"selec"] forState:UIControlStateNormal];
        enterpriseBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -30, 0, 0);
        [_typeView addSubview:enterpriseBtn];
        
        
        UIButton *setDefaultBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        setDefaultBtn.frame = CGRectMake(SCREEN_WIDTH - 120, 13.5, 100, 20);
        [setDefaultBtn setTitle:@"设置默认" forState:UIControlStateNormal];
        [setDefaultBtn setTitleColor:[UIColor colorWithHex:0x666666] forState:UIControlStateNormal];
        setDefaultBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [setDefaultBtn setImage:[UIImage imageNamed:@"selec"] forState:UIControlStateNormal];
        setDefaultBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
        [_typeView addSubview:setDefaultBtn];
        
        
    }
    return _typeView;
}


- (UIView *)editView {
    if (!_editView) {
        
        _editView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_typeView.frame), SCREEN_WIDTH, SCREEN_HEIGHT - CGRectGetMaxY(_typeView.frame))];
        [self.view addSubview:_editView];
        NSArray *array = @[@{@"* 名称：" : @"请输入抬头名称"}, @{@"* 社会统一信用证代码：" : @"请输入纳税人识别号"},  @{@"企业地址：" : @"请输入企业注册地址"}, @{@"电话号码：" : @"请输入企业电话号码"},@{ @"开户银行：" : @"请输入企业开户银行"},@{ @"银行账户：" : @"请输入企业银行账户"}];
        for (NSInteger i = 0; i < array.count; i++) {
            
            NSDictionary *dic = array[i];
            UILabel *nameLabel = [UILabel new];
            nameLabel.textColor = [UIColor colorWithHex:0x333333];
            nameLabel.font = [UIFont systemFontOfSize:14];
            CGSize titleSize = [ [[dic allKeys] objectAtIndex:0] sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
            nameLabel.frame = CGRectMake(10, 10 + 30 * i, titleSize.width + 10, 20);
            nameLabel.text = [[dic allKeys] objectAtIndex:0];
            [_editView addSubview:nameLabel];
            
            
            UITextField *tf= [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(nameLabel.frame) + 10, nameLabel.mj_y, SCREEN_WIDTH - CGRectGetMaxX(nameLabel.frame) - 20, 20)];
            tf.font = [UIFont systemFontOfSize:14];
            tf.placeholder = [[dic allValues] objectAtIndex:0];
            [_editView addSubview:tf];
            [_editView layoutIfNeeded];
        }
    }
    return _editView;
}

- (void)backAction:(UIBarButtonItem *)item {
    
    [self.navigationController popViewControllerAnimated:YES];
    
}



@end
